package com.github.code.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.github.code.R;
import com.github.wui.MarqueeLayout.MarqueeLayout;
import com.github.wui.MarqueeLayout.MarqueeViewAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="https://github.com/karai-oss">Mr.xie</a>
 * @Date 2025/4/30
 */
public class TickAdapter extends MarqueeViewAdapter {

    private List<String> data = new ArrayList<>();

    private Context context;

    public TickAdapter(List<String> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int count() {
        return this.data.size();
    }

    @NonNull
    @Override
    public View loadingInnerView(@NotNull MarqueeLayout tickerLayout) {
        return LayoutInflater.from(context).inflate(R.layout.layout_tick_item, tickerLayout, false);
    }

    @Override
    public void setInnerView(@NotNull View view, int pos, @NotNull MarqueeLayout tickerLayout) {
        TextView text = view.findViewById(R.id.tv_text);
        text.setText(data.get(pos));
    }
}
